cmake_minimum_required(VERSION 3.6)
project(tpu-runtime)

set(COMMIT_HASH "xxxxxxxx")
set (BRANCH_NAME "unknown")
execute_process(COMMAND date +%Y%m%d-%H:%M:%S OUTPUT_VARIABLE COMPILE_TIME)
execute_process(COMMAND git rev-parse --git-dir RESULT_VARIABLE result OUTPUT_QUIET)
if(result EQUAL 0)
    execute_process(COMMAND git describe --always --abbrev=8 OUTPUT_VARIABLE COMMIT_HASH)
    execute_process(COMMAND bash -c "git branch --contains HEAD | sed -n '/\* /s///p'" OUTPUT_VARIABLE BRANCH_NAME)
endif()
STRING(STRIP ${COMMIT_HASH} COMMIT_HASH)
STRING(STRIP ${BRANCH_NAME} BRANCH_NAME)
STRING(STRIP ${COMPILE_TIME} COMPILE_TIME)

message(STATUS "COMMIT_HASH: ${COMMIT_HASH}, BRANCH_NAME: ${BRANCH_NAME}, COMPILE_TIME: ${COMPILE_TIME}")
configure_file("${PROJECT_SOURCE_DIR}/config/bmrt_version.h.in" "${CMAKE_BINARY_DIR}/bmrt_version.h")

if("$ENV{ONLY_TEST}" STREQUAL "1")
include(test.cmake)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include(old.cmake)
else()
set(CMAKE_CXX_STANDARD 17)
include(new.cmake)
endif()
